<template>
  <div class="all">
    <div class="title">
      <div>{{ this.title }}</div>
      <div>
        <el-button type="primary" icon="el-icon-back" @click="goBack">返回</el-button>
        <el-button type="primary" icon="el-icon-document-checked">保存</el-button>
      </div>
    </div>
    <div class="detail-mid">
      <el-form ref="form" :model="data" inline>
        <el-row>
          <el-col :span="4">
            <el-form-item label="编号：">
              <el-input v-model="data.coding" />
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-form-item label="名称：">
              <el-input v-model="data.name" />
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-form-item label="成本中心：">
              <v-select v-model="data.cost_id" action="costList/1" />
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-form-item label="类别：">
              <SelfSelect v-model="data.category" :showList="paramCategoryOption" />
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-form-item label="状态：">
              <SelfSelect v-model="data.status" :showList="status" />
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-form-item label="预警偏低：">
              <el-input v-model="data.notice_low" />
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-form-item label="预警过低：">
              <el-input v-model="data.warning_low" />
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-form-item label="预警偏高：">
              <el-input v-model="data.notice_high" />
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-form-item label="预警过高：">
              <el-input v-model="data.warning_high" />
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-form-item label="单位：">
              <el-input v-model="data.unit" />
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-form-item label="标准：">
              <el-input v-model="data.standard" />
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-form-item label="排序：">
              <el-input v-model="data.sort" />
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
    </div>
    <div v-if="this.editId" class="detail-bottom">
      <el-tabs v-model="activeName">
        <el-tab-pane label="描述" name="one">
          <div class="one">
            <div style="width: 15%">
              <p>创建时间日期</p>
              <el-input v-model="data.create_time" disabled />
              <p>创建人</p>
              <el-input v-model="data.cr_admin.name" disabled />
              <p>最近更新</p>
              <el-input v-model="data.update_time" disabled />
              <p>更新者</p>
              <el-input v-model="data.up_admin.name" disabled />
            </div>
            <div style="width: 84%;padding: 2px">
              <Edit v-model="data.content" :height="250" id="edit" />
            </div>
          </div>
        </el-tab-pane>
      </el-tabs>
    </div>
  </div>
</template>

<script>
import API from '@/api/asset/param'
import SelfSelect from '@/components/select-o'
import VSelect from '@/components/select'
import Edit from '@/components/Tinymce/index'
import { paramCategoryOption, status } from '@/utils/option'
export default {
  inject: ['goUrl', 'isEdit'],
  components: {
    SelfSelect,
    VSelect,
    Edit
  },
  data() {
    return {
      data: {
        cr_admin: {
          name: ''
        },
        up_admin: {
          name: ''
        }
      },
      editId: null,
      title: '',
      paramCategoryOption,
      status,
      activeName: 'one'
    }
  },
  created() {
    const edit = this.isEdit()
    if (edit) {
      this.title = '更新设备'
      this.editId = edit
      this.info()
    } else {
      this.title = '新增设备'
    }
  },
  methods: {
    goBack() {
      this.$router.push('/asset/param')
    },
    info() {
      API.getOne(this.editId).then(res => {
        this.data = res.data
      })
    }
  }
}
</script>

<style scoped>
.one{
  display: flex;
  justify-content: space-between;
}
</style>
